<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header"></head>

<style type="text/css">
    .table {
        table-layout: fixed;
        word-break: break-all;
    }

    .table td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .cell-wrap-text {
        white-space: normal !important;
        word-break: break-all;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="col-sm-12">
        <div class="ibox">
            <div class="ibox-body">
                <div class="fixed-table-toolbar">
                    <input id="applicationId" th:value="${parentId}" name="applicationId" class="form-control"
                           type="hidden">
                    <div class="columns pull-left">
                        <button shiro:hasPermission="jzweb:eventresourceAllocation:add" type="button"
                                class="btn  btn-primary" onclick="add()">
                            <i class="fa fa-plus" aria-hidden="true"></i>添加
                        </button>
                        <button shiro:hasPermission="jzweb:eventresourceAllocation:add" type="button"
                                class="btn  btn-danger"
                                onclick="batchRemove()">
                            <i class="fa fa-trash" aria-hidden="true"></i>删除
                        </button>
                        <div class=" pull-right ">
                            <button  type="button"
                                     class="btn  btn-primary" onclick="editGroupType()">
                                修改组别
                            </button>
                            <div class=" pull-right ">
                                <select id="groupType" name="groupType" class="form-control" style="margin-right: 20px">
                                    <option value="">请选择组别</option>
                                    <option value="1">中职组</option>
                                    <option value="2">高校组</option>
                                    <option value="3">教师组</option>
                                    <option value="4">国际组</option>
                                    <option value="5">通用</option>
                                </select>
                            </div>
                        </div>
                        <button  type="button"
                                 class="btn  btn-primary" onclick="editVedio()">
                            修改视频封面图
                        </button>
                        <div class=" pull-right ">
                            <input id="fmpic" type="text" class="form-control"
                                   placeholder="请输入需要截取视频的秒数">
                        </div>

                    </div>
                    <div class="columns pull-right">
                        <button class="btn btn-success" onclick="reLoad()">查询</button>
                    </div>
                    <div class="columns pull-right  nopadding">
                        <input id="searchName" type="text" class="form-control"
                               placeholder="请输入标题名称">
                    </div>
                    <div class="columns pull-right  nopadding">
                        <select id="searchState" name="searchState" class="form-control" style="margin-right: 20px">
                            <option value="">请选择资源类型筛选</option>
                            <option value="0">赛项规程</option>
                            <option value="1">在线题库</option>
                            <option value="2">竞赛试题</option>
                            <option value="3">模拟赛场</option>
                            <option value="4">专家点评</option>
                            <option value="5">技能参考</option>
                            <option value="6">赛场再现</option>
                            <option value="7">物料清单</option>
                        </select>
                        <select class="form-control valid" id="xtype" type="hidden" style="display: none" disabled name="searchState">
                            <option value="">请选择</option>
                            <option value="0">证书标准</option>
                            <option value="1">在线题库</option>
                            <option value="2">课程标准</option>
                            <option value="3">模拟考场</option>
                            <option value="4">考评标准</option>
                            <option value="5">技能参考</option>
                            <option value="6">考评物料</option>
                        </select>
                    </div>
                </div>
                <table id="exampleTable" data-mobile-responsive="true">
                </table>
            </div>
        </div>
    </div>
</div>
<!--shiro控制bootstraptable行内按钮看见性 -->
<div>
    <script type="text/javascript">
        var s_edit_h = 'hidden';
        var s_remove_h = 'hidden';
        var s_resetPwd_h = 'hidden';
    </script>
</div>
<div shiro:hasPermission="jzweb:eventresourceAllocation:add">
    <script type="text/javascript">
        s_edit_h = '';
    </script>
</div>
<div shiro:hasPermission="jzweb:eventresourceAllocation:add">
    <script type="text/javascript">
        var s_remove_h = '';
    </script>
</div>
<div shiro:hasPermission="jzweb:eventresourceAllocation:add">
    <script type="text/javascript">
        var s_resetPwd_h = '';
    </script>
</div>
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript"
        src="/js/webJs/eventresource/eventresourceAllocations/eventresourceAllocations.js?r=119"></script>
<script>
    function editGroupType(){
        var rows = $('#exampleTable').bootstrapTable('getSelections');
        var allocationId =sessionStorage.getItem('zallocationId')
        console.log(allocationId,222)
        var ids = new Array();
        // 遍历所有选择的行数据，取每条数据对应的ID
        $.each(rows, function (i, row) {
            ids[i] = row['id'];
        });
        if(ids.length<1){
            layer.msg('至少勾选一个资源')
            return false;
        }
        $.ajax({
            url: "/jzweb/eventresourceAllocations/updateGroup",
            type: "post",
            data: JSON.stringify({
                'allocationsIds': ids,
                'groupType':$('#groupType').val(),
                'allocationId':allocationId
            }),
            contentType:'application/json',
            success: function (r) {
                if (r.code == 0) {
                    layer.msg(r.msg);
                    reLoad();
                } else {
                    layer.msg(r.msg);
                }
            }
        });
    }
</script>
</body>
</html>